import {FormSchema} from "@/types/schema";

// 与vue2的里面的data一样，函数返回新对象防止多处共用同一对象,造成数据混乱
export const getFormSchema = (): FormSchema => ({
    formItem: [
        {
            type: "input",
            label: "帐号",
            field: "username",
            value: '',
            props: {
                placeholder: "请输入帐号"
            },
            rules: [
                {
                    required: true,
                    message: "帐号不能为空",
                }
            ]
        },
        {
            type: "input",
            label: "姓名",
            field: "nickName",
            value: '',
            props: {
                placeholder: "请输入姓名"
            },
            rules: [
                {
                    required: true,
                    message: "姓名不能为空",
                }
            ]
        },
        {
            type: "input",
            label: "邮箱",
            field: "email",
            value: '',
            props: {
                placeholder: "请输入邮箱"
            },
            rules: [
                {
                    required: true,
                    message: '邮箱不能为空'
                },
                {
                    pattern: new RegExp(/^(?:[a-z0-9]+[_\-+.]+)*[a-z0-9]+@(?:([a-z0-9]+-?)*[a-z0-9]+.)+([a-z]{2,})+$/i),
                    message: "邮箱格式不正确"
                }
            ]
        },
        {
            type: "input",
            label: "密码",
            field: "password",
            hidden: false, // 是否隐藏
            value: '',
            props: {
                type: 'password',
                placeholder: "请输入密码"
            },
            rules: [
                {
                    "required": true,
                    "message": "密码不能为空"
                }
            ]
        },
        {
            type: "textarea",
            label: "备注",
            field: "note",
            value: '',
            props: {
                placeholder: "请输入备注",
                rows: 5
            },
            rules: [
                {
                    required: false
                }
            ]
        }
    ]
})
